function random(max,min){
    return Math.floor(Math.random() * (max-min+1)+min)
}
jj=setInterval(function(event){
event=event||window.event
var img=document.createElement('img')
img.src="./star.gif"
 var w=random(50,40)
 img.style.width=w+'px'
 img.style.height=w+'px'
 
 var maxw=random((window.innerWidth||document.documentElement.clientWidth)-w,0)
 var maxh=random((window.innerHeight||document.documentElement.clientHeight)-w,0)
 img.style.position='absolute'
 img.style.left=maxw+'px'
 img.style.top=maxh+'px'
 document.body.appendChild(img)
}
,500)
var b=document.body


var num=300
var sum=60
var dd=setInterval(function(){
num--
num--
num--
num--
num--
num--
num--
var xue=document.querySelector('div span')
xue.style.width=num+'px'
var b=document.body

b.onclick=function(event){
event=event||window.event
var target=event.target||event.srcElement
//console.log(target)
if(target.nodeName=="IMG"){
    b.removeChild(target)
    num++
    num++
    num++
}
}
     sum--
     if(num<=0){
alert('你输了')  
clearInterval(dd)
clearInterval(jj)
     }
   
     if(sum<=0&&num>0){
     
       alert('你赢了')
       clearInterval(dd)
       clearInterval(jj)
     }
   
}
,1000)

var btn=document.querySelector('button')
btn.onclick=function(){
location.reload()
}
